package br.com.friendzone.componentes;

import java.util.ArrayList;
import java.util.List;

/**
 * Classe vinculada ao Auto Complete.tag
 * 
 * @author Jackson Silva
 * 
 */
public class Source {
	private String identificacao;

	private String label;

	private String urlImg;

	private List<Source> sources;

	public List<Source> getSources() {
		if( sources == null){
			this.setSources( new ArrayList<Source>());
		}
		return sources;
	}

	public void setSources(List<Source> sources) {
		this.sources = sources;
	}

	public String getIdentificacao() {
		return identificacao;
	}

	public void setIdentificacao(String identificacao) {
		this.identificacao = identificacao;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getUrlImg() {
		return urlImg;
	}

	public void setUrlImg(String urlImg) {
		this.urlImg = urlImg;
	}

	@Override
	public String toString() {

		if( sources == null || sources.isEmpty() ){
			return super.toString();
		}
		final StringBuffer sourceStr = new StringBuffer();
		sourceStr.append("[ ");
		for( int index =0; index < sources.size(); index++ ){
			final Source source = sources.get(index);
			sourceStr.append("{\"id\":").append(" \""+source.identificacao+"\", ");
			sourceStr.append("\"label\":").append(" \""+source.label+"\"");
			
			if( (index+1) == sources.size() ){
				sourceStr.append("}");
			}else{
				sourceStr.append("},");
			}
		}
		sourceStr.append(" ]");

		return sourceStr.toString();
	}
}
